-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(expect): objectContaining
traversing non vanilla Objects
#10720
Conversation
Hi @scagood! Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Could you add a changelog entry?
this.sample[property], | ||
); | ||
if ( | ||
samplePropertyPrototype === Object.prototype || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might break for cases hit by #2549, but 🤞 it does not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it does break, afaik the next best ways to check for "plain objects" are Object.getPrototypeOf(sample)?.constructor?.name === 'Object'
and Object.prototype.toString.call(sample) ...
. These are imprecise, but at least they work across realms.
Array.isArray()
could be substituted for the Array.prototype
check to fix that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I can confirm that this is broken for cross-realm inputs, like in #2549. ninevra@0553005 adds a failing test on top of this PR to demonstrate the issue.
Honestly, with #10508 in, is this still any different from what
Does that pass the tests? |
I am unable to get the correct people to sign the CLA, therefore I can only close this PR. I am sorry. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Attempting to fix the bug found in #10716
Summary
This change will change
objectContaining
to only recursively step into vanilla sub-objectsTest Plan
Added new test cases to cover this behaviour